﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="Ribbon.Documents.NotifyChangeDocument"
                Location="CommandUI.Ribbon"
                RegistrationType="List"
                RegistrationId="99001">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Workflow.Moderate"/><!--Remove Approve/Reject menu item-->
        <CommandUIDefinition Location="Ribbon.Documents.Groups._children">
          <Group Id="Ribbon.Documents.NotifyChangeDocument"
                 Title="Notification"
                 Description="Document Notification"
                 Sequence="25"
                 Template="Ribbon.Templates.MsdnTemplate">
            <Controls Id="Ribbon.Documents.NotifyChangeDocument.Controls">              
              <Button Id="Ribbon.Documents.NotifyChangeDocument.CustomHelpButton"
                      LabelText="Hello"
                      Description="Say hello to the user"
                      ToolTipDescription="Simply say 'hello' to the user"
                      ToolTipTitle="Hint title"
                      ToolTipImage32by32="/_layouts/Images/CreditAgricole/CALogo32.png"
                      TemplateAlias="o1"
                      Sequence="15"
                      Image16by16="/_layouts/Images/CreditAgricole/CALogo16.png"
                      Image32by32="/_layouts/Images/CreditAgricole/CALogo32.png"
                      Command="NotifyChangeDocument.OnGetHelp" />
              <Button Id="Ribbon.Documents.NotifyChangeDocument.CustomApplyPrefixButton"
                      LabelText="Show Item ID"
                      TemplateAlias="o2"
                      Sequence="17"
                      Image16by16="/_layouts/Images/CreditAgricole/CALogo16.png"
                      Image32by32="/_layouts/Images/CreditAgricole/CALogo32.png"
                      Command="NotifyChangeDocument.OnShowID" />
              <Button Id="Ribbon.Documents.NotifyChangeDocument.CustomPageComponentButton"
                      LabelText="Do Nothing"
                      TemplateAlias="o3"
                      Sequence="19"
                      Image16by16="/_layouts/Images/CreditAgricole/CALogo16.png"
                      Image32by32="/_layouts/Images/CreditAgricole/CALogo32.png"
                      Command="NotifyChangeDocument.OnDoNothing" />
            </Controls>
          </Group>
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Documents.Scaling._children">
          <MaxSize Id="Ribbon.Documents.Scaling.NotifyChangeDocument.MaxSize"
                   GroupId="Ribbon.Documents.NotifyChangeDocument"
                   Size="OneBigTwoSmall"
                   Sequence="15" />
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Templates._children">
          <GroupTemplate Id="Ribbon.Templates.MsdnTemplate">
            <Layout Title="MsdnHorizontal">
              <Section Type="OneRow">
                <Row>
                  <ControlRef DisplayMode="Large" TemplateAlias="o1" />
                  <ControlRef DisplayMode="Large" TemplateAlias="o2" />
                  <ControlRef DisplayMode="Large" TemplateAlias="o3" />
                </Row>
              </Section>
            </Layout>
            <Layout Title="MsdnVertical">              
              <Section Type="ThreeRow">
                <Row>
                  <ControlRef DisplayMode="Medium" TemplateAlias="o1" />
                </Row>
                <Row>
                  <ControlRef DisplayMode="Medium" TemplateAlias="o2" />
                </Row>
                <Row>
                  <ControlRef DisplayMode="Medium" TemplateAlias="o3" />
                </Row>
              </Section>
            </Layout>
            <Layout Title="OneBigTwoSmall">
              <Section Type="OneRow">
                <Row>
                  <ControlRef DisplayMode="Large" TemplateAlias="o1"/>
                </Row>
              </Section>              
              <Section Type="TwoRow" Alignment="Middle">
                <Row>
                  <ControlRef DisplayMode="Medium" TemplateAlias="o2"/>
                </Row>
                <Row>
                  <ControlRef DisplayMode="Medium" TemplateAlias="o3"/>
                </Row>
              </Section>
            </Layout>
            <Layout Title="MsdnVerticalTextOnly">
              <Section Type="ThreeRow">
                <Row>
                  <ControlRef DisplayMode="Menu" TemplateAlias="o1" />
                </Row>
                <Row>
                  <ControlRef DisplayMode="Menu" TemplateAlias="o2" />
                </Row>
                <Row>
                  <ControlRef DisplayMode="Menu" TemplateAlias="o3" />
                </Row>
              </Section>
            </Layout>
          </GroupTemplate>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="NotifyChangeDocument.OnGetHelp"
                          CommandAction="javascript:alert('Hello Credit Agricole !');"       
                          EnabledScript="javascript:
        function checkIsEnabled(){
          // Check items selected.
          var selectedItems = SP.ListOperation.Selection.getSelectedItems();
          var count = CountDictionary(selectedItems);
          return (count > 1);
        };
                      
        checkIsEnabled();"/>
        
        <CommandUIHandler Command="NotifyChangeDocument.OnShowID"
                          CommandAction="javascript:
                              var selectedItem = SP.ListOperation.Selection.getSelectedItems()[0];
                              alert(selectedItem.id);"
                          EnabledScript="javascript:
        function checkIsEnabled(){
          // Check items selected.
          var selectedItems = SP.ListOperation.Selection.getSelectedItems();
          var count = CountDictionary(selectedItems);
          return (count == 1);
        };
                      
        checkIsEnabled();"/>
        <CommandUIHandler Command="NotifyChangeDocument.OnDoNothing"
                          CommandAction="javascript:void(0);"
                          EnabledScript="true"/>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
